<template>
    <div>

        <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>

        <el-card>


            <el-row :gutter="10">

                <el-table :data="dataList" style="width: 100%" border stripe>
                    <el-table-column type="index" label="序号" width="180">
                    </el-table-column>
                    <el-table-column prop="name" label="权限名称" width="180">
                    </el-table-column>
                    <el-table-column prop="url" label="url" width="180">
                    </el-table-column>
                    <el-table-column prop="level" label="等级">

                        <template slot-scope="scope">
                            <el-tag type="success" v-if="scope.row.level == 0">一级权限</el-tag>
                            <el-tag type="info" v-if="scope.row.level == 1">二级权限</el-tag>
                            <el-tag type="warning" v-if="scope.row.level == 2">三级权限</el-tag>
                        </template>
                    </el-table-column>


                </el-table>
            </el-row>

            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :page-sizes="[1, 2, 3, 4]" :page-size="permission.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="permission.total">
            </el-pagination>

        </el-card>

    </div>
</template>
<script>
import { getList } from '@/api/Permission.js'
export default {
    name: "permissionList",
    data() {
        return {
            dataList: [],
            permission: {
                pageNum: 1,
                pageSize: 5,
                total: 10
            }
        }
    }, methods: {
        searchPermission() {
            getList(this.permission).then(res => {
                console.log('res111', res)
                this.dataList = res.data.data.list;
                this.permission.total = res.data.data.total
            })
        }, handleCurrentChange(val) {
            this.permission.pageNum = val;
            this.searchPermission();

        }, handleSizeChange(val) {
            this.permission.pageSize = val;
            this.searchPermission();
        }

    },
    created() {
        this.searchPermission();
    }
}

</script>
<style scoped>
.el-pagination {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

/* 在此添加组件的样式 */
</style>